Component({
    options: {
        multipleSlots: true,
        addGlobalClass: true
    },
    properties: {
        title: {
            type: String,
            value: ''
        },
        extClass: {
            type: String,
            value: ''
        },
        maskClosable: {
            type: Boolean,
            value: true
        },
        mask: {
            type: Boolean,
            value: true
        },
        show: {
            type: Boolean,
            value: false,
            observer: '_showChange'
        },
        buttons: {
            type: Array,
            value: []
        }
        ,
        statusColor:{
            type:String,
            value:""
        }
    },
    data: {
        innerShow: false
    },
    ready: function ready() {
        var buttons = this.data.buttons;
        var len = buttons.length;
        buttons.forEach(function(btn, index) {
            if (len === 1) {
                btn.className = 'weui-dialog__btn_primary';
            } else if (index === 0) {
                btn.className = 'weui-dialog__btn_default';
            } else {
                btn.className = 'weui-dialog__btn_primary';
            }
        });
        this.setData({
            buttons: buttons
        });
    },

    methods: {
        //微信小程序调用自定义组件的内的事件
        buttonTap0: function buttonTap(e) {
            var index = e.currentTarget.dataset.index;
            this.triggerEvent('buttontap0', { index: index, item: this.data.buttons[index] }, {});
        },
        buttonTap1: function buttonTap(e) {
            var index = e.currentTarget.dataset.index;
            this.triggerEvent('buttontap1', { index: index, item: this.data.buttons[index] }, {});
        },
        close: function close() {
            var data = this.data;
            if (!data.maskClosable) return;
            this.setData({
                show: false
            });
            this.triggerEvent('close', {}, {});
        },

        /**
         * 点击遮罩层，如果点击的是确认按钮，则不触发
         */
        clickMask: function(e) {
            console.log(e);
        },
        stopEvent: function stopEvent() {}
    }
});